package com.atguigu.gmall.common.execption.handler;


import com.atguigu.gmall.common.execption.GmallException;
import com.atguigu.gmall.common.result.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

//全局异常处理器
//@ResponseBody
//@ControllerAdvice
@RestControllerAdvice
public class GlobalExceptionController {



    @ExceptionHandler(GmallException.class)
    public Result handleException(GmallException e){
        Result<Object> fail = Result.fail();
        fail.setCode(e.getCode());
        fail.setMessage(e.getMessage());
        return fail;
    }


}
